﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;


namespace ERP.Classes
{
    public class cs_hmr_nhanvienInfo
    {
        private int _manhanvien;
        private string _hoten;
        private string _bidanh;
        private DateTime _ngaysinh;
        private string _gioitinh;
        private string _vanhoa;
        private string _ngoaingu;
        private string _sotruong;
        private string _chuyenmon;
        private string _trinhdo;
        private string _ngayluuhs;
        private string _lydoluuhs;
        private int _trangthai;
        private string _dantoc;
        private string _tongiao;
        private string _sobhxh;
        private string _noi_dkkcb;
        private string _nhanvien_id;
        private string _ngaynhap;
        private int _nguoinhap;
        private string _ngaysua;
        private int _nguoisua;
        private string _socmnd;
        private DateTime _ngaycap;
        private string _noicap;
        private string _didong;
        private string _dienthoaiban;
        private string _diachiemail;
        private string _masothue;
        private string _diachi;
        private string _quequan;
        private string _website;

        private string _bangcapkhac;
        private string _chungchikhac;
        private string _uudiem;
        private string _khuyetdiem;
        private string _diachilienhe;
        private string _kinhnghiem;



        
        public cs_hmr_nhanvienInfo()
        {
            this._manhanvien = 0;
            this._hoten = " ";
            this._bidanh = " ";
            this._ngaysinh = Convert.ToDateTime("01/01/9999");
            this._gioitinh = " ";
            this._vanhoa = " ";
            this._ngoaingu = " ";
            this._sotruong = " ";
            this._chuyenmon = " ";
            this._trinhdo = " ";
            this._ngayluuhs = " ";
            this._lydoluuhs = " ";
            this._trangthai = 0;
            this._dantoc = " ";
            this._tongiao = " ";
            this._sobhxh = " ";
            this._noi_dkkcb = " ";
            this._nhanvien_id = " ";
            this._ngaynhap = " ";
            this._nguoinhap = 0;
            this._ngaysua = " ";
            this._nguoisua = 0;
            this._socmnd = " ";
            this._ngaycap = Convert.ToDateTime("01/01/9999");
            this._noicap = " ";
            this._didong = " ";
            this._dienthoaiban = " ";
            this._diachiemail = " ";
            this._masothue = " ";
            this._diachi = " ";
            this._quequan = " ";
            this._website = " ";

            this._bangcapkhac = " ";
            this._chungchikhac = " ";
            this._uudiem = " ";
            this._khuyetdiem = " ";
            this._diachilienhe = " ";
            this._kinhnghiem = " ";
        }
        public int manhanvien
        {
            get
            {
                return this._manhanvien;
            }
            set
            {
                this._manhanvien = value;
            }
        }
        public string hoten
        {
            get
            {
                return this._hoten;
            }
            set
            {
                this._hoten = value;
            }
        }
        public string bidanh
        {
            get
            {
                return this._bidanh;
            }
            set
            {
                this._bidanh = value;
            }
        }
        public DateTime ngaysinh
        {
            get
            {
                return this._ngaysinh;
            }
            set
            {
                this._ngaysinh = value;
            }
        }
        public string gioitinh
        {
            get
            {
                return this._gioitinh;
            }
            set
            {
                this._gioitinh = value;
            }
        }
        public string vanhoa
        {
            get
            {
                return this._vanhoa;
            }
            set
            {
                this._vanhoa = value;
            }
        }
        public string ngoaingu
        {
            get
            {
                return this._ngoaingu;
            }
            set
            {
                this._ngoaingu = value;
            }
        }
        public string sotruong
        {
            get
            {
                return this._sotruong;
            }
            set
            {
                this._sotruong = value;
            }
        }
        public string chuyenmon
        {
            get
            {
                return this._chuyenmon;
            }
            set
            {
                this._chuyenmon = value;
            }
        }
        public string trinhdo
        {
            get
            {
                return this._trinhdo;
            }
            set
            {
                this._trinhdo = value;
            }
        }
        public string ngayluuhs
        {
            get
            {
                return this._ngayluuhs;
            }
            set
            {
                this._ngayluuhs = value;
            }
        }
        public string lydoluuhs
        {
            get
            {
                return this._lydoluuhs;
            }
            set
            {
                this._lydoluuhs = value;
            }
        }
        public int trangthai
        {
            get
            {
                return this._trangthai;
            }
            set
            {
                this._trangthai = value;
            }
        }
        public string dantoc
        {
            get
            {
                return this._dantoc;
            }
            set
            {
                this._dantoc = value;
            }
        }
        public string tongiao
        {
            get
            {
                return this._tongiao;
            }
            set
            {
                this._tongiao = value;
            }
        }
        public string sobhxh
        {
            get
            {
                return this._sobhxh;
            }
            set
            {
                this._sobhxh = value;
            }
        }
        public string noi_dkkcb
        {
            get
            {
                return this._noi_dkkcb;
            }
            set
            {
                this._noi_dkkcb = value;
            }
        }
        public string nhanvien_id
        {
            get
            {
                return this._nhanvien_id;
            }
            set
            {
                this._nhanvien_id = value;
            }
        }
        public string ngaynhap
        {
            get
            {
                return this._ngaynhap;
            }
            set
            {
                this._ngaynhap = value;
            }
        }
        public int nguoinhap
        {
            get
            {
                return this._nguoinhap;
            }
            set
            {
                this._nguoinhap = value;
            }
        }
        public string ngaysua
        {
            get
            {
                return this._ngaysua;
            }
            set
            {
                this._ngaysua = value;
            }
        }
        public int nguoisua
        {
            get
            {
                return this._nguoisua;
            }
            set
            {
                this._nguoisua = value;
            }
        }
        public string socmnd
        {
            get
            {
                return this._socmnd;
            }
            set
            {
                this._socmnd = value;
            }
        }
        public DateTime ngaycap
        {
            get
            {
                return this._ngaycap;
            }
            set
            {
                this._ngaycap = value;
            }
        }
        public string noicap
        {
            get
            {
                return this._noicap;
            }
            set
            {
                this._noicap = value;
            }
        }
        public string didong
        {
            get
            {
                return this._didong;
            }
            set
            {
                this._didong = value;
            }
        }
        public string dienthoaiban
        {
            get
            {
                return this._dienthoaiban;
            }
            set
            {
                this._dienthoaiban = value;
            }
        }
        public string diachiemail
        {
            get
            {
                return this._diachiemail;
            }
            set
            {
                this._diachiemail = value;
            }
        }
        public string masothue
        {
            get
            {
                return this._masothue;
            }
            set
            {
                this._masothue = value;
            }
        }
        public string diachi
        {
            get
            {
                return this._diachi;
            }
            set
            {
                this._diachi = value;
            }
        }
        public string quequan
        {
            get
            {
                return this._quequan;
            }
            set
            {
                this._quequan = value;
            }
        }
        public string website
        {
            get
            {
                return this._website;
            }
            set
            {
                this._website = value;
            }
        }

        public string bangcapkhac
        {
            get
            {
                return this._bangcapkhac;
            }
            set
            {
                this._bangcapkhac = value;
            }
        }
        public string chungchikhac
        {
            get
            {
                return this._chungchikhac;
            }
            set
            {
                this._chungchikhac = value;
            }
        }
        public string uudiem
        {
            get
            {
                return this._uudiem;
            }
            set
            {
                this._uudiem = value;
            }
        }
        public string khuyetdiem
        {
            get
            {
                return this._khuyetdiem;
            }
            set
            {
                this._khuyetdiem = value;
            }
        }

        public string diachilienhe
        {
            get
            {
                return this._diachilienhe;
            }
            set
            {
                this._diachilienhe = value;
            }
        }
        public int ExcuteProcedure(int option)
        {
            return this.ExcuteStoreProcedure("Proc_HMR_NHANVIEN", option);
        }

        public string kinhnghiem
        {
            get
            {
                return this._kinhnghiem;
            }
            set
            {
                this._kinhnghiem = value;
            }
        }

        public int ExcuteStoreProcedure(string storeProcedure, int option)
        {
            string[] paraName = new string[39];
            paraName[0] = "@manhanvien";
            paraName[1] = "@hoten";
            paraName[2] = "@bidanh";
            paraName[3] = "@ngaysinh";
            paraName[4] = "@gioitinh";
            paraName[5] = "@vanhoa";
            paraName[6] = "@ngoaingu";
            paraName[7] = "@sotruong";
            paraName[8] = "@chuyenmon";
            paraName[9] = "@trinhdo";
            paraName[10] = "@ngayluuhs";
            paraName[11] = "@lydoluuhs";
            paraName[12] = "@trangthai";
            paraName[13] = "@dantoc";
            paraName[14] = "@tongiao";
            paraName[15] = "@sobhxh";
            paraName[16] = "@noi_dkkcb";
            paraName[17] = "@nhanvien_id";
            paraName[18] = "@ngaynhap";
            paraName[19] = "@nguoinhap";
            paraName[20] = "@ngaysua";
            paraName[21] = "@nguoisua";
            paraName[22] = "@socmnd";
            paraName[23] = "@ngaycap";
            paraName[24] = "@noicap";
            paraName[25] = "@didong";
            paraName[26] = "@dienthoaiban";
            paraName[27] = "@diachiemail";
            paraName[28] = "@masothue";
            paraName[29] = "@diachi";
            paraName[30] = "@quequan";
            paraName[31] = "@website";
            paraName[32] = "@bangcapkhac";
            paraName[33] = "@chungchikhac";
            paraName[34] = "@uudiem";
            paraName[35] = "@khuyetdiem";
            paraName[36] = "@diachilienhe";
            paraName[37] = "@kinhnghiem";
            paraName[38] = "@option";
            object[] paraValue = new object[39];
            paraValue[0] = this._manhanvien;
            paraValue[1] = this._hoten;
            paraValue[2] = this._bidanh;
            paraValue[3] = this._ngaysinh;
            paraValue[4] = this._gioitinh;
            paraValue[5] = this._vanhoa;
            paraValue[6] = this._ngoaingu;
            paraValue[7] = this._sotruong;
            paraValue[8] = this._chuyenmon;
            paraValue[9] = this._trinhdo;
            paraValue[10] = this._ngayluuhs;
            paraValue[11] = this._lydoluuhs;
            paraValue[12] = this._trangthai;
            paraValue[13] = this._dantoc;
            paraValue[14] = this._tongiao;
            paraValue[15] = this._sobhxh;
            paraValue[16] = this._noi_dkkcb;
            paraValue[17] = this._nhanvien_id;
            paraValue[18] = this._ngaynhap;
            paraValue[19] = this._nguoinhap;
            paraValue[20] = this._ngaysua;
            paraValue[21] = this._nguoisua;
            paraValue[22] = this._socmnd;
            paraValue[23] = this._ngaycap;
            paraValue[24] = this._noicap;
            paraValue[25] = this._didong;
            paraValue[26] = this._dienthoaiban;
            paraValue[27] = this._diachiemail;
            paraValue[28] = this._masothue;
            paraValue[29] = this._diachi;
            paraValue[30] = this._quequan;
            paraValue[31] = this._website;
            paraValue[32] = this._bangcapkhac;
            paraValue[33] = this._chungchikhac;
            paraValue[34] = this._uudiem;
            paraValue[35] = this._khuyetdiem;
            paraValue[36] = this._diachilienhe;
            paraValue[37] = this._kinhnghiem;
            paraValue[38] = option;
            csCSDL csdl = new csCSDL();
            int i = 0;
            i = csdl.CreateParameters(paraName, 39, paraValue);
            return csdl.ExcuteStoreProcedure(storeProcedure);
        }
        
        public int Get_Info()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                ds = csdl.OpenTable("HMR_NHANVIEN", "nhanvien_id = '" + this._nhanvien_id + "'");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                this._manhanvien = Convert.ToInt32(ds.Tables[0].Rows[0]["manhanvien"].ToString().Trim());
                this._hoten = ds.Tables[0].Rows[0]["hoten"].ToString().Trim();
                this._bidanh = ds.Tables[0].Rows[0]["bidanh"].ToString().Trim();
                this._ngaysinh = Convert.ToDateTime(ds.Tables[0].Rows[0]["ngaysinh"].ToString().Trim());
                this._gioitinh = ds.Tables[0].Rows[0]["gioitinh"].ToString().Trim();
                this._vanhoa = ds.Tables[0].Rows[0]["vanhoa"].ToString().Trim();
                this._ngoaingu = ds.Tables[0].Rows[0]["ngoaingu"].ToString().Trim();
                this._sotruong = ds.Tables[0].Rows[0]["sotruong"].ToString().Trim();
                this._chuyenmon = ds.Tables[0].Rows[0]["chuyenmon"].ToString().Trim();
                this._trinhdo = ds.Tables[0].Rows[0]["trinhdo"].ToString().Trim();
                this._ngayluuhs = ds.Tables[0].Rows[0]["ngayluuhs"].ToString().Trim();
                this._lydoluuhs = ds.Tables[0].Rows[0]["lydoluuhs"].ToString().Trim();
                this._trangthai = Convert.ToInt32(ds.Tables[0].Rows[0]["trangthai"].ToString().Trim());
                this._dantoc = ds.Tables[0].Rows[0]["dantoc"].ToString().Trim();
                this._tongiao = ds.Tables[0].Rows[0]["tongiao"].ToString().Trim();
                this._sobhxh = ds.Tables[0].Rows[0]["sobhxh"].ToString().Trim();
                this._noi_dkkcb = ds.Tables[0].Rows[0]["noi_dkkcb"].ToString().Trim();
                this._nhanvien_id = ds.Tables[0].Rows[0]["nhanvien_id"].ToString().Trim();
                this._ngaynhap = ds.Tables[0].Rows[0]["ngaynhap"].ToString().Trim();
                this._nguoinhap = Convert.ToInt32(ds.Tables[0].Rows[0]["nguoinhap"].ToString().Trim());
                this._ngaysua = ds.Tables[0].Rows[0]["ngaysua"].ToString().Trim();
                this._nguoisua = Convert.ToInt32(ds.Tables[0].Rows[0]["nguoisua"].ToString().Trim());
                this._socmnd = ds.Tables[0].Rows[0]["socmnd"].ToString().Trim();
                this._ngaycap = Convert.ToDateTime(ds.Tables[0].Rows[0]["ngaycap"].ToString().Trim());
                this._noicap = ds.Tables[0].Rows[0]["noicap"].ToString().Trim();
                this._didong = ds.Tables[0].Rows[0]["didong"].ToString().Trim();
                this._dienthoaiban = ds.Tables[0].Rows[0]["dienthoaiban"].ToString().Trim();
                this._diachiemail = ds.Tables[0].Rows[0]["diachiemail"].ToString().Trim();
                this._masothue = ds.Tables[0].Rows[0]["masothue"].ToString().Trim();
                this._diachi = ds.Tables[0].Rows[0]["diachi"].ToString().Trim();
                this._quequan = ds.Tables[0].Rows[0]["quequan"].ToString().Trim();
                this._website = ds.Tables[0].Rows[0]["website"].ToString().Trim();
                this._bangcapkhac = ds.Tables[0].Rows[0]["bangcapkhac"].ToString().Trim();
                this._chungchikhac = ds.Tables[0].Rows[0]["chungchikhac"].ToString().Trim();
                this._uudiem = ds.Tables[0].Rows[0]["uudiem"].ToString().Trim();
                this._khuyetdiem = ds.Tables[0].Rows[0]["khuyetdiem"].ToString().Trim();
                this._diachilienhe = ds.Tables[0].Rows[0]["diachilienhe"].ToString().Trim();
                this._kinhnghiem = ds.Tables[0].Rows[0]["kinhnghiem"].ToString().Trim();
                return 1;
            }
            catch
            {
                return -1;
            }
        }

        public DataSet Get_List_Congtac()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                string sql = "select a.manvpb, b.tenchucdanh, c.tendonvi, d.tendonvi as captren, a.ngaybatdau, a.ngayketthuc"
                        + " from hmr_nv_pb a"
                        + " left join hmr_chucdanh b on (b.machucdanh = a.chucdanh)"
                        + " left join hmr_donvi c on (c.madonvi = a.maphongban)"
                        + " left join hmr_donvi d on (d.madonvi = c.captren)"
                        + " where a.manhanvien = " + this.manhanvien
                        + " order by a.trangthai asc";
                ds = csdl.SelecSQL(sql);
                
                
                return ds;
            }
            catch
            {
                return null;
            }
        }

        public DataSet Get_List_Hopdong()
        {
            csCSDL csdl = new csCSDL();
            DataSet ds = new DataSet("ds");
            try
            {
                string sql = "select a.manv_hd, b.tenloai, a.ghichu, c.tendonvi, a.ngaybatdau, a.ngayketthuc"
                        + " from hmr_hopdong_nhanvien a"
                        + " left join hmr_loaihopdong b on (b.maloai = a.maloaihd)"
                        + " left join hmr_donvi c on (c.madonvi = a.madv)"
                        + " where a.manv = " + this.manhanvien
                        + " order by a.trangthaihd asc";
                ds = csdl.SelecSQL(sql);


                return ds;
            }
            catch
            {
                return null;
            }
        }
    }
}
